package dao.impl;

import dao.IShopDao;
import model.Cart;
import model.Goods;
import model.Order;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public class ShopDao implements IShopDao {
    @Autowired
    private SqlSession sqlSession;
    @Override
    public List<Goods> selectGoods(Goods goods) {
        return sqlSession.selectList("dao.IShopDao.selectGoods", goods);
    }

    @Override
    public List<Goods> selectParentId(Goods goods) {
        return sqlSession.selectList("dao.IShopDao.selectParentId", goods);
    }

    @Override
    public List<Goods> selectSortId(Goods goods) {
        return  sqlSession.selectList("dao.IShopDao.selectSortId", goods);
    }

    @Override
    public int insertCart(Cart cart) {
        return  sqlSession.insert("dao.IShopDao.insertCart", cart);
    }

    @Override
    public List<Goods> selectCart(Cart cart) {
        return  sqlSession.selectList("dao.IShopDao.selectCart", cart);
    }

    @Override
    public int updateCount(Goods goods) {
        return  sqlSession.update("dao.IShopDao.updateCount", goods);
    }

    @Override
    public int count(Cart cart) {
        return  sqlSession.selectOne("dao.IShopDao.count", cart);
    }

    @Override
    public int insertOrder(Order order) {
        return  sqlSession.insert("dao.IShopDao.insertOrder", order);
    }

    @Override
    public int deleteCrat(Integer id) {
        return  sqlSession.delete("dao.IShopDao.deleteCart", id);
    }

    @Override
    public List<Order> selectOrder(Order order) {
        return  sqlSession.selectList("dao.IShopDao.selectOrder", order);
    }


}
